package com.sz.app.oss.api.pay.transfer;

import com.sz.biz.app.web.BaseController;
import com.sz.biz.common.constants.MessagesCodes;
import com.sz.biz.pay.transfer.dto.ConfirmedDto;
import com.sz.biz.pay.transfer.dto.RechargeDto;
import com.sz.biz.pay.transfer.dto.WithdrawalsDto;
import com.sz.biz.pay.transfer.service.RechargeWithdrawalsService;
import com.sz.common.base.dto.ResultDto;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Function: 帐户提现与充值 <br>
 *
 * @author: siqishangshu <br>
 * @date: 2017-12-04 18:25:00
 */
@RestController
@RequestMapping("/api/v1/rechargewithdrawals")
@Api(description = "帐户提现与充值", tags = "51、提现与充值")
public class RechargewithdrawalsController extends BaseController {

    @Autowired
    private RechargeWithdrawalsService rechargeWithdrawalsService;

    @ApiOperation(value = "通过银行卡对帐户进行充值")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ThirdCustId", value = "会员代码", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "TranAmount", value = "交易金额", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "BankNo", value = "选择银行卡号", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "BankName", value = "银行卡", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "CcyCode", value = "币种", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "Note", value = "备注", required = true, dataType = "String", paramType = "body")})
    @RequestMapping(value = "/recharge", method = RequestMethod.POST)
    public ResultDto recharge(@RequestBody @ApiParam(value = "通过银行卡对帐户进行充值", required = true) RechargeDto rechargeDto) {
        ResultDto resultDto = rechargeWithdrawalsService.recharge(rechargeDto);
        if (resultDto.getData().equals(Boolean.TRUE)) {
            resultDto = getOperateSuccessDto(MessagesCodes.MODULE_PAY_RECHARGE_SUCCESS);
        }else{
            resultDto = getOperateSuccessDto(MessagesCodes.MODULE_PAY_RECHARGE_FAILED);
        }
        resultDto.setData(rechargeDto);
        return resultDto;
    }

    @ApiOperation(value = "帐户提现")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "CustAcctId", value = "子账户账号", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "ThirdCustId", value = "交易网会员代码", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "CustName", value = "子账户名称", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "OutAcctId", value = "提现账号", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "OutAcctIdName", value = "提现账户名称", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "CcyCode", value = "币种", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "TranAmount", value = "申请提现金额", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "HandFee", value = "提现手续费", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "Note", value = "备注", required = true, dataType = "String", paramType = "body")})
    @RequestMapping(value = "/withdrawals", method = RequestMethod.POST)
    public ResultDto withdrawals(@RequestBody @ApiParam(value = "帐户提现", required = true) WithdrawalsDto withdrawalsDto) {
        ResultDto resultDto = rechargeWithdrawalsService.withdrawals(withdrawalsDto);
        if (resultDto.getData().equals(Boolean.TRUE)) {
            resultDto = getOperateSuccessDto(MessagesCodes.MODULE_PAY_WITHDRAWALS_SUCCESS);
        }else{
            resultDto = getOperateSuccessDto(MessagesCodes.MODULE_PAY_WITHDRAWALS_FAILED);
        }
        resultDto.setData(withdrawalsDto);
        return resultDto;

    }

    @ApiOperation(value = "帐户提现前手续费")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "CustAcctId", value = "子账户账号", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "ThirdCustId", value = "交易网会员代码", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "CustName", value = "子账户名称", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "OutAcctId", value = "提现账号", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "OutAcctIdName", value = "提现账户名称", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "CcyCode", value = "币种", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "TranAmount", value = "申请提现金额", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "Note", value = "备注", required = true, dataType = "String", paramType = "body")})
    @RequestMapping(value = "/withdrawals/handFee", method = RequestMethod.POST)
    public ResultDto withdrawalsHandFee(@RequestBody @ApiParam(value = "帐户提现前手续费", required = true) WithdrawalsDto withdrawalsDto) {
        return rechargeWithdrawalsService.withdrawalsHandFee(withdrawalsDto);
    }

    @ApiOperation(value = "出金平台确认")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "transactionId", value = "流水号", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "tranStatus", value = "审核状态", required = true, dataType = "String", paramType = "body"),
            @ApiImplicitParam(name = "note", value = "备注", required = true, dataType = "String", paramType = "body")})
    @RequestMapping(value = "/withdrawals/confirmed/",method = RequestMethod.POST)
    public ResultDto withdrawalsConfirmed(@RequestBody @ApiParam(value = "帐户提现前手续费", required = true) ConfirmedDto confirmed) {
        return rechargeWithdrawalsService.withdrawalsConfirmed(confirmed);
    }
}

